<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../style/css/style.css" rel="stylesheet" type="text/css"/>
    <script src="../../style/js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function (){
            findNewsTypeList();
        })

        function findNewsTypeList(){
            $.get("../../news/passList",function (res){
                if(res==500){
                    alert("服务器繁忙,请稍后再试");
                }else {
                    console.log(res);
                    var str = "";
                    for (var i = 0; i < res.data.length; i++) {
                        var  imgsrc ="http://127.0.0.1:8888/userImg/coverImg/"+res.data[i].coverImg;
                        str += "<tr align='center'>";
                        str += "<td>"+(i+1)+"</td>";
                        str += "<td>"+res.data[i].title+"</td>";
                        str += "<td>"+res.data[i].abstracts+"</td>";
                        if(res.data[i].coverImg==null||res.data[i].coverImg==undefined||res.data[i].coverImg==""){
                            str += "<td>未上传广告图</td>";
                        }else{
                            str += "<td><img src='"+imgsrc+"' width='50px' height='50px'></td>";
                        }
                        str += "<td>"+res.data[i].content+"</td>";
                        str += "<td>"+new Date(res.data[i].releaseTime).toLocaleString()+"</td>";
                        str += "<td>"+res.data[i].newsType.name+"</td>";


                        str +="<td><a href='javaScript:void(0)' onclick='pass("+res.data[i].id+")'>通过</a>"+
                            "&nbsp;&nbsp;<a href='javaScript:void(0)' onclick='unPass("+res.data[i].id+")'>不通过</a></td>";
                        str += "</tr>";
                    }
                    $("#tableId").append(str);
                }
            },"json")
        }

        function pass(id){
            if(confirm("确定通过此新闻吗?"+id)){
                $.post("../../news/pass",{id:id},function (res){
                    if(res.code==200){
                        alert("操作成功");
                        location.assign("pass.html");
                        return;
                    }else{
                        alert("服务器繁忙....");
                        return;
                    }
                })
            }
        }

        function unPass(id){
            if(confirm("确定不通过此新闻吗?"+id)){
                $.post("../../news/unPass",{id:id},function (res){
                    if(res.code==200){
                        alert("操作成功");
                        location.assign("pass.html");
                        return;
                    }else{
                        alert("服务器繁忙....");
                        return;
                    }
                })
            }
        }
    </script>




</head>


<body>
<div class="rightinfo">
    <!-- 顶部按钮 -->
    <div class="tools">
        <ul class="toolbar">
            <a href="add.html">
                <li class="click">
                    <span><img src="../../style/img/adminMainPicture/t01.png" /></span>
                    添加
                </li>
            </a>
            &nbsp;&nbsp;&nbsp;
            <a href="pass.html">
                <li class="click">
                    <span><img src="../../style/img/adminMainPicture/t01.png" /></span>
                    新闻审核
                </li>
            </a>
        </ul>
    </div>
    <!--数据列表 -->
    <form >
        <table class="tablelist" id="tableId">
            <th>编号<i class="sort"><img src="../../style/img/adminMainPicture/px.gif" /></i></th>
            <th>标题</th>
            <th>摘要</th>
            <th>封面图</th>
            <th>内容</th>
            <th>发布时间</th>
            <th>新闻类型</th>
            <th>审核</th>
        </table>
    </form>
</div>
</body>
</html>
